//
//  CGNetManage.h
//  Onskysell
//
//  Created by cg on 17/3/6.
//  Copyright © 2017年 cg. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#import "UIKit+AFNetworking.h"
#import "CGUrlManage.h"
#import "MBProgressHUD.h"

typedef void (^HZCompletedBlock)(NSString *resultMessage, id data);
typedef void (^HZFailedBlock)(NSString *resultcode, id data);
typedef void (^HZErrorBlock)(id data);
typedef void(^LJCompleteBlock)(NSURLSessionDataTask *task, id responseObject);
typedef void(^LJFailBlock)(NSURLSessionDataTask *task, NSError *error);
@interface CGNetManage : NSObject


/**
 单例

 @return CGNetManage
 */
+ (CGNetManage *)shared;

/**
 图片上传服务器
 
 */
+ (void)httpPostImg:(UIImage *)img compress:(CGFloat)compress success:(LJCompleteBlock)success fail:(LJFailBlock)fail;

/**
 检测是否有网络

 @return 是否有网
 */
+ (BOOL) isReachable;

//get
- (NSURLSessionTask *)httpGet:(NSString *)url params:(NSDictionary *)paramsDic completed:(HZCompletedBlock)completeBlock failed:(HZFailedBlock )failedBlock error:(HZErrorBlock) errorBlock;

/**
 post网络请求

 @param url 请求地址
 @param paramsDic 参数
 @param completeBlock 返回value
 @param failedBlock 网络错误
 @param errorBlock 异常
 @return return
 */
- (NSURLSessionTask *)httpPost:(NSString *)url params:(NSDictionary *)paramsDic completed:(HZCompletedBlock)completeBlock failed:(HZFailedBlock )failedBlock error:(HZErrorBlock) errorBlock;

//版本检查
- (void)httpCheckVersionWithCompleted:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpInitPageWithUrlLink:(NSString *)urlLink Completed:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;


// **************** 原生app部分 ***************
- (void)httpGetHomeDataWithCompleted:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpGetCateListWithCompleted:(void(^)(NSArray *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpGetGoodsListWithParams:(NSDictionary *)paramsDic Completed:(void(^)(NSArray *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpGetGoodsDetailWithParams:(NSDictionary *)paramsDic Completed:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpGetOrderListWithParams:(NSDictionary *)paramsDic Completed:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpLoginWithParams:(NSDictionary *)paramsDic Completed:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;

- (void)httpAddCart:(NSDictionary *)paramsDic Completed:(void(^)(NSDictionary *))completeBlock fail:(void(^)(NSError *))failBlock;

@end
